package com.wandian.util;

import java.util.Random;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class ThreadSafeRandom
{
	private Random random = new Random();

	public int next() {
		synchronized (this) {
			return this.random.nextInt();
		}
	}

	public int next(int maxValue) {
		synchronized (this) {
			return this.random.nextInt(maxValue);
		}
	}

	public int next(int minValue, int maxValue)
	{
		synchronized (this) {
			if (minValue < maxValue) {
				return this.random.nextInt(maxValue - minValue) + minValue;
			}
		}
		return minValue;
	}
}
